// --------------------------------------------------------------------- // // Pict2DIB.c - Sample QuickTime for Windows Application // // Reads the PICT data from the PICT file specified on the command // line into global memory, casts the PicHandle to access the PICT, and // demonstrates using the PicHandle to create a .BMP file containing a // DIB. // // dib.h and the WriteDIB function are available from Microsoft on the // Microsoft Visual C++ and Microsoft Developer Network CD-ROMS. // // Copyright 1988-1996 Apple Computer, Inc. All Rights Reserved. // // --------------------------------------------------------------------- static char szAppName[] = "Pict2DIB"; #include <windows.h>#include <qtw.h>#include "dib.h" #define MB_Ret(msg, code) \ { MessageBox (NULL, msg, szAppName, MB_OK); return code; } int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int CmdShow) { HFILE hfile; DWORD lSize; HANDLE hGlobalMem; char huge * hpGlobalMem; DIBHandle hdPicture; // Open file and find its size hfile = _lopen (lpszCmdParam, READ); if (hfile==HFILE_ERROR) MB_Ret ("_lopen failure", 0); lSize = _llseek (hfile, 0, 2); // Allocate enough global memory for Pict data and obtain huge pointer hGlobalMem = GlobalAlloc (GPTR, lSize-512); hpGlobalMem = (char huge *)GlobalLock (hGlobalMem); // Read Pict data from file into global memory and close file _llseek (hfile, 512L, 0); _hread (hfile, hpGlobalMem, lSize-512); _lclose (hfile); // Cast global memory handle and use as PicHandle hdPicture = PictureToDIB ((PicHandle)hGlobalMem); WriteDIB ("pictout.bmp", hdPicture); // Unlock and free global memory GlobalUnlock (hGlobalMem); GlobalFree (hGlobalMem); // Display MessageBox and exit MB_Ret (lpszCmdParam, TRUE); }